<!--报表中心-->
<template>
	<div class="m-view-masterMenu m-window">
		<div class="m-module" v-for="(item,index) in menu" :key="index">
			<div class="m-title">{{item.title}}</div>
			<ul>
				<li
					v-for="(list,serial) in item.list"
					:key="(serial)"
					@click="addTab(list)"
					:class="{'m-completed':list.completed}"
				>
					<i :class="'iconfont icon-' + list.name"></i>
					<span>{{list.cName}}</span>
				</li>
			</ul>
		</div>
	</div>
</template>

<script>
import utils from "@/public/utils";
import authorize from "@/public/authorize";

export default {
	data () {
		return {
			menu: [
				{
					title: "报表中心",
					list: [
						// {
						// 	cName: "订单追踪",
						// 	name: "purchaseTrackingReport",
						// 	completed: true
						// },
						// {
						// 	cName: "对账跟踪",
						// 	name: "accountReport",
						// 	completed: true
						// },
						// {
						// 	cName: "系统运行监控",
						// 	name: "systemOperationReport",
						// 	completed: true
						// },
						// {
						// 	cName: "送货看板",
						// 	name: "deliveryReport",
						// 	completed: true
						// },
						// {
						// 	cName: "防伪码查询",
						// 	name: "counterfeitionCodeReport",
						// 	completed: true
						// },
						// {
						// 	cName: "对账函融资报表",
						// 	name: "accountletterReport",
						// 	completed: true
						// },
						// {
						// 	cName: "对账统计",
						// 	name: "accountTotalReport",
						// 	completed: true
						// },
						// {
						// 	cName: "功能使用统计",
						// 	name: "functionUseReport",
						// 	completed: true
						// },
						// {
						// 	cName: "实物对账明细报表",
						// 	name: "goodsAccountReport",
						// 	completed: true
						// },
						// {
						// 	cName: "融资合同报表",
						// 	name: "fincontractReport",
						// 	completed: true
						// },
						// {
						// 	cName: "上线情况跟踪",
						// 	name: "onlineReport",
						// 	completed: true
						// },
						// {
						// 	cName: "对账看板",
						// 	name: "accountBoardReport",
						// 	completed: true
						// },
						// {
						// 	cName: "会计对账明细",
						// 	name: "accountMxReport",
						// 	completed: true
						// },
					]
				}
			]
		};
	},
	props: {
		addTab: {
			type: Function
		}
	},
	methods: {
		getMenuDetails () {
			let parentId = utils.getMenuId("menuId"); // 菜单ID
			let activeMenu = [];
			authorize.getMenuAuth(parentId).then((res) => {
				if (Array.isArray(res) && res.length > 0) {
					this.menu.forEach((menu, index) => {
						activeMenu.push({
							title: menu.title,
							list: [],
						});
						res.forEach((item) => {
							activeMenu[index].list.push({
								name: item.code,
								cName: item.name,
								completed: true,
							});
						});
					});
					this.menu = activeMenu;
				}
			});
		}
	},
	components: {},
	beforeMount () {
		this.getMenuDetails();
	}
};
</script>

<style>
</style>